package com.ufo.store.management.widget.view;

import android.content.Context;
import android.support.v4.widget.NestedScrollView;
import android.util.AttributeSet;

/**
 * Created by taoli on 2017/11/6.
 */

public class ObservableNestedScrollView extends NestedScrollView {
    private NestedScrollViewListener scrollViewListener = null;

    public ObservableNestedScrollView(Context context) {
        super(context);
    }

    public ObservableNestedScrollView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    public ObservableNestedScrollView(Context context, AttributeSet attrs) {
        super(context,attrs);
        setFadingEdgeLength(0);
    }

    public void setNestedScrollViewListener(NestedScrollViewListener scrollViewListener) {
        this.scrollViewListener = scrollViewListener;
    }

    @Override
    protected void onScrollChanged(int x, int y, int oldx, int oldy) {
        super.onScrollChanged(x, y, oldx, oldy);
        if (scrollViewListener != null) {
            scrollViewListener.onScrollChanged(this, x, y, oldx, oldy);
        }
    }

    public interface NestedScrollViewListener {
        void onScrollChanged(ObservableNestedScrollView scrollView, int x, int y, int oldx, int oldy);
    }

}
